import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:gold/base/provider_scaffold.dart';
import 'package:gold/http/apis.dart';
import 'package:gold/ui/rules/rules_viewmodel.dart';
import 'package:gold/utils/xfg_color.dart';
import 'package:gold/utils/xfg_size.dart';
import 'package:gold/widgets/common_widgets.dart';
import 'package:gold/widgets/xfg_text.dart';

/// @description: 规则说明
/// @author tangzhentao
/// @created at 20:35 2024/12/15

class RulesPage extends StatelessWidget {
  /// 加载配置的key [Apis.config]
  final String config;
  /// 标题
  final String? title;

  const RulesPage({super.key, required this.config, this.title});

  @override
  Widget build(BuildContext context) {
    return ProviderScaffold<RulesViewmodel>(
      model: RulesViewmodel(config),
      onInit: (data) => data.loadConfig(),
      appBar: (_) => xfgAppbar(title: title?? '规则说明'),
      builder: (ctx, rules) => HtmlWidget(rules.content),
      // body: Container(
      //   margin: EdgeInsets.fromLTRB(XfgSize().size10, XfgSize().size25, XfgSize().size10, 0),
      //   padding: EdgeInsets.fromLTRB(0, XfgSize().size26, XfgSize().size10, XfgSize().size28),
      //   decoration: BoxDecoration(color: XfgColor.colorE, borderRadius: BorderRadius.circular(XfgSize().size16)),
      //   child: Column(
      //     crossAxisAlignment: CrossAxisAlignment.start,
      //     mainAxisSize: MainAxisSize.min,
      //     children: [
      //       Container(
      //         margin: EdgeInsets.only(left: XfgSize().size15),
      //         child: XfgText('注销提示', fontSize: XfgSize().text18, color: XfgColor.text1, bold: FontWeight.bold),
      //       ),
      //       Container(
      //         margin: EdgeInsets.only(left: XfgSize().size15, top: XfgSize().size18),
      //         alignment: Alignment.centerLeft,
      //         child: XfgText('请您认真阅读账户注销后的影响：', fontSize: XfgSize().text16, color: XfgColor.text1D),
      //       ),
      //       _rulesItemWidget('注销后平台不保留用户任何信息'),
      //       _rulesItemWidget('注销后不能在使用注销账号登陆，但可以重新注册'),
      //       _rulesItemWidget('有未结算订单不允许注销'),
      //       _rulesItemWidget('注销后余额资金将一起被抹除'),
      //       _rulesItemWidget('注销申请将会在7个工作日内受理'),
      //     ],
      //   ),
      // ),
    );
  }

  /// 规则信息布局
  Widget _rulesItemWidget(String text) => Container(
    margin: EdgeInsets.only(top: XfgSize().size14),
    child: Row(
      children: [
        Container(
          width: XfgSize().size15,
          alignment: Alignment.center,
          child: Container(width: XfgSize().size4, height: XfgSize().size4, decoration: const BoxDecoration(color: XfgColor.text3, shape: BoxShape.circle)),
        ),
        Expanded(child: XfgText(text, fontSize: XfgSize().text16, color: XfgColor.text1D))
      ],
    ),
  );
}
